package com.kcn.download;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.kcn.utils.PropertiesReader;
import com.opensymphony.xwork2.ActionSupport;
public class ShowdownloadAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private List<String> filelist = new ArrayList<String>();

	public List<String> getFilelist() {

		return filelist;
	}

	public void setFilelist(List<String> filelist) {
		this.filelist = filelist;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		filelist.clear();
		String filePath = PropertiesReader.getPropertiesReader().getProperty(
				"downloadPath");
		System.out.println("文件路径："+filePath);
		File file = new File(filePath);
		System.out.println("文件路径："+file.getAbsolutePath());
		File[] tempfilelist = file.listFiles();
		System.out.println("filelist 长度："+filelist.size());
		for(int i=0;i<filelist.size();i++){
			System.out.println("文件列表:"+filelist.get(i));
		}
		if (tempfilelist.equals(null)) {
			System.out.println("filelist is null");
		} else {
			for (int i = 0; i < tempfilelist.length; i++) {
				// System.out.println(tempfilelist.length);
				if (!tempfilelist[i].isDirectory()) {
					filelist.add(tempfilelist[i].getName());
//					System.out.println(tempfilelist[i].getName());
				}
//				System.out.println(filelist.size());
			}
		}
		return super.execute();
	}
}
